﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<GradeBook.Models.TaskInfo>" %>

<%@ Import Namespace="System.Diagnostics" %>
<%@ Import Namespace="GradeBook.Daos" %>
<%@ Import Namespace="GradeBook.Models" %>
<%@ Import Namespace="GradeBook.Security" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Задание
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% if (Model != null)
       { %>
    <% using (Html.BeginForm())
       { %>
    <table>
        <caption>
            Задание № <b>
                <%= Html.Encode(Model.Id) %></b>
                <%= Html.HiddenFor(m => m.Id) %>
        </caption>
        <tr>
            <td>
                Описание задания:
            </td>
            <td>
                <%= Html.Encode(Model.Description) %>
            </td>
        </tr>
        <tr>
            <td>
                Опубликовал:
            </td>
            <td>
                <% if (Model.OwnerId != null)
                   { %>
                <% User user = UserDao.GetById((int)Model.OwnerId); %>
                <%= Html.HiddenFor(m => m.OwnerId) %>
                <%= Html.Encode(string.Format("{0} {1}", user.FirstName, user.LastName)) %>
                <% } %>
            </td>
        </tr>
        <tr>
            <td>
                Вывод:
            </td>
            <td>
                <%
                    RelTaskUser relTaskUser = null;
                    using (GradeBookEntities db = new GradeBookEntities())
                    {
                        int userId = MemShPrvd.CurrUser().Id;
                        relTaskUser = db.RelTaskUser.FirstOrDefault(m => m.TaskId == Model.Id && m.UserId == userId);
                    }
            %>
            <% if (relTaskUser.TaskMark == 0)
               { %>
                <%= Html.TextAreaFor(m => m.Conclusion, new {@Value = Model.Conclusion, rows = 12, cols = 50}) %>
                <% } else { %> 
                <%= Html.Encode(Model.Conclusion) %>
                <% } %>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="right">
                <input type="submit" value="Подтвердить"/>
            </td>
        </tr>
    </table>
    <% } %>
    <% } %>
</asp:Content>
